package com.yc.sole.framework.utils;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.read.listener.ReadListener;
import lombok.extern.slf4j.Slf4j;

import java.util.ArrayList;
import java.util.List;

/**
 * @author yizuomin
 * @date 2022/12/8 17:27
 **/
@Slf4j
public class ExcelListener<T> implements ReadListener<T> {

    private final List<T> dataList = new ArrayList<>();

    public List<T> getDataList() {
        return dataList;
    }

    @Override
    public void invoke(T data, AnalysisContext context) {
        dataList.add(data);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext context) {
        log.info("解析完成！读取{}行", dataList.size());
    }
}
